﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using SystemCenterSoa.DtoModel.SystemManager.ApplyGather;
using SystemCenterSoa.PoModel.SystemManager.ApplyGather;
using SystemCenterSoa.Service.SystemManager.ApplyGather;

namespace SystemCenterSoa.ApiProject.Area.SystemManager.ApplyGather
{
    public class DepartmentActivityApplyController : SystemManagerBaseController
    {
        private DepartmentActivityApplyService _departmentActivityApplyService;

        public DepartmentActivityApplyController(DepartmentActivityApplyService departmentActivityApplyService)
        {
            _departmentActivityApplyService = departmentActivityApplyService;
        }
        [HttpPost]
        public bool GetDepartmentActivityApplyAdd(DepartmentActivityApplyPo departmentActivityApply)
        {
            return _departmentActivityApplyService.GetDepartmentActivityApplyAdd(departmentActivityApply);
        }
        [HttpGet]
        public IActionResult GetDepartmentActivityApplyList(int deId, string nian, string yue, int pageIndex, int pageSize)
        {
            try
            {
                var query = _departmentActivityApplyService.GetDepartmentActivityApplyList(deId, nian, yue, pageIndex, pageSize);
                var total = query.Count();
                var list = query.OrderBy(t => t.bmhd_id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
                return Ok(new { list, total });
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public DepartmentActivityApplyPo GetDepartmentActivityApplyFan(int id)
        {
            return _departmentActivityApplyService.GetDepartmentActivityApplyFan(id);
        }
        [HttpPost]
        public bool GetDepartmentActivityApplyUpdate(DepartmentActivityApplyPo departmentActivityApply)
        {
            return _departmentActivityApplyService.GetDepartmentActivityApplyUpdate(departmentActivityApply);
        }
        [HttpPost]
        public bool GetDepartmentActivityApplyDel(string ids)
        {
            return _departmentActivityApplyService.GetDepartmentActivityApplyDel(ids);
        }
    }
}
